﻿<%@ Page Title="" Language="C#" MasterPageFile="~/manager/page/ManagerMasterPage.Master" AutoEventWireup="true" CodeBehind="pageauth.aspx.cs" Inherits="Com.Web.coffinegurunaru.manager.manager.pageauth" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="Com.Library.DB.PageAuth" %>
<asp:Content ID="Content1" ContentPlaceHolderID="phHead" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="phContent" runat="server">

<hr />
<br />
<table>
<tr>
	<td valign="top">
		<table cellpadding="0" cellspacing="1" style="background-color:Gray; width:100px;">
		<tr>
			<td style="background-color:White; text-align:center; height:50px;"><a href="/manager/manager/manager.aspx">관리자</a></td>
		</tr>
		<%if (IsManager == 1)
	{ %>
		<tr>
			<td style="background-color:Silver; text-align:center; height:50px;"><a href="/manager/manager/pageauth.aspx">권한 설정</a></td>
		</tr>
		<% } %>
		</table>
	</td>
	<td style="width:20px;"></td>
	<td valign="top">

<table>
<tr>
<td style="text-align:center;" valign="top">
				<table class="managerList" style="border-color:red; border-style:solid;" border="1px;" >
                <thead>
                <tr style="height:30px;">
                    <td style="width:80px; text-align:center">SN</td>
                    <td style="width:150px; text-align:center">아이디</td>
                    <td style="width:150px; text-align:center">이름</td>
                    <td>-</td>
                </tr>
                </thead>
                <tbody>
                </tbody>
                </table>
                <div class="pager"></div>
</td>
<td style="width:30px">&nbsp;</td>
<td >
<% 
	if ( this.ManagerSN != 0 ) {
%>
			<table>
<%
		List<PageMainTypeEntity> MainList = GetMainPageList();
		foreach (PageMainTypeEntity mitem in MainList)
		{
			PageAuthMainEntity MainAuthInfo = GetMainAuthInfo(mitem.MainPageType);
%>
			<tr>
				<td>
					<table cellpadding="0" cellspacing="1" style="background-color:Gray; width:100px;">
					<tr>
						<td style="background-color:#eeeeee; text-align:center; height:30px;"><%=mitem.stName %></td>
					</tr>
					<tr style="background-color:White;">
						<td style="text-align:center;" data="{'MainPageType':'<%=mitem.MainPageType %>'}">
							<select class="m_selMainPageType">
								<option value="0" <%=MainAuthInfo.CodeAuthType == 0 ? "selected='selected'" : ""%>>권한없음</option>
								<option value="1" <%=MainAuthInfo.CodeAuthType == 1 ? "selected='selected'" : ""%>>권한있음</option>
							</select>
						</td>
					</tr>
					</table>
				</td>
				<td style="width:20px;">
				</td>
<%
			foreach(PageSubTypeEntity item in GetSubPageList(mitem.MainPageType)) {
				PageAuthSubEntity SubAuthInfo = GetSubAuthInfo(mitem.MainPageType, item.SubPageType);
%>
				<td>
					<table cellpadding="0" cellspacing="1" style="background-color:Gray; width:100px;">
					<tr>
						<td style="background-color:#eeeeee; text-align:center; height:30px;"><%=item.Name %></td>
					</tr>
					<tr style="background-color:White;">
						<td style="text-align:center;" data="{'MainPageType':'<%=item.MainPageType %>', 'SubPageType':'<%=item.SubPageType %>'}">
							<select class="m_selSubPageType">
								<option value="0" <%=SubAuthInfo.CodeAuthType == 0 ? "selected='selected'" : ""%>>권한없음</option>
								<option value="1" <%=SubAuthInfo.CodeAuthType == 1 ? "selected='selected'" : ""%>>권한있음</option>
							</select>
						</td>
					</tr>
					</table>
				</td>
<%			} %>
<%		} %>
			</tr>
			</table>
<hr />			
			<table>
			<tr>
				<td>
					<table cellpadding="0" cellspacing="1" style="background-color:Gray; width:100px;">
					<tr>
						<td style="background-color:#eeeeee; text-align:center; height:30px;">문의사항<br />상세설정</td>
					</tr>
					</table>
				</td>
				<td style="width:20px;">
				</td>
				<td>
					<table cellpadding="0" cellspacing="1" style="background-color:Gray; width:100px;">
					<tr>
						<td style="background-color:#eeeeee; text-align:center; height:30px;">마케팅,기획,프로모션 제휴</td>
					</tr>
					<tr style="background-color:White;">
						<td style="text-align:center;" data="{'MainPageType':'1000', 'SubPageType':'0'}">
							<select class="m_selSubPageType">
								<option value="0" <%=IsCategoryCheck(0) == false ? "selected='selected'" : "" %>>권한없음</option>
								<option value="1" <%=IsCategoryCheck(0) == true ? "selected='selected'" : "" %>>권한있음</option>
							</select>
						</td>
					</tr>
					</table>
				</td>
				<td>
					<table cellpadding="0" cellspacing="1" style="background-color:Gray; width:100px;">
					<tr>
						<td style="background-color:#eeeeee; text-align:center; height:30px;">원,부자재 문의</td>
					</tr>
					<tr style="background-color:White;">
						<td style="text-align:center;" data="{'MainPageType':'1000', 'SubPageType':'1'}">
							<select class="m_selSubPageType">
								<option value="0" <%=IsCategoryCheck(1) == false ? "selected='selected'" : "" %>>권한없음</option>
								<option value="1" <%=IsCategoryCheck(1) == true ? "selected='selected'" : "" %>>권한있음</option>
							</select>
						</td>
					</tr>
					</table>
				</td>
				<td>
					<table cellpadding="0" cellspacing="1" style="background-color:Gray; width:100px;">
					<tr>
						<td style="background-color:#eeeeee; text-align:center; height:30px;">채용문의</td>
					</tr>
					<tr style="background-color:White;">
						<td style="text-align:center;" data="{'MainPageType':'1000', 'SubPageType':'2'}">
							<select class="m_selSubPageType">
								<option value="0" <%=IsCategoryCheck(2) == false ? "selected='selected'" : "" %>>권한없음</option>
								<option value="1" <%=IsCategoryCheck(2) == true ? "selected='selected'" : "" %>>권한있음</option>
							</select>
						</td>
					</tr>
					</table>
				</td>
				<td>
					<table cellpadding="0" cellspacing="1" style="background-color:Gray; width:100px;">
					<tr>
						<td style="background-color:#eeeeee; text-align:center; height:30px;">가맹점문의</td>
					</tr>
					<tr style="background-color:White;">
						<td style="text-align:center;" data="{'MainPageType':'1000', 'SubPageType':'3'}">
							<select class="m_selSubPageType">
								<option value="0" <%=IsCategoryCheck(3) == false ? "selected='selected'" : "" %>>권한없음</option>
								<option value="1" <%=IsCategoryCheck(3) == true ? "selected='selected'" : "" %>>권한있음</option>
							</select>
						</td>
					</tr>
					</table>
				</td>
				<td>
					<table cellpadding="0" cellspacing="1" style="background-color:Gray; width:100px;">
					<tr>
						<td style="background-color:#eeeeee; text-align:center; height:30px;">고객의 소리</td>
					</tr>
					<tr style="background-color:White;">
						<td style="text-align:center;" data="{'MainPageType':'1000', 'SubPageType':'4'}">
							<select class="m_selSubPageType">
								<option value="0" <%=IsCategoryCheck(4) == false ? "selected='selected'" : "" %>>권한없음</option>
								<option value="1" <%=IsCategoryCheck(4) == true ? "selected='selected'" : "" %>>권한있음</option>
							</select>
						</td>
					</tr>
					</table>
				</td>
			</tr>
			</table>
<% } %>


</td>
</tr>
</table>


	</td>
</tr>
</table>

<script type="text/javascript">
if ($.Manager == null)
	$.Manager = {};

$.Manager.getList = function()
{
	$.ajaxNet(
		"/manager/manager/managermethod.aspx?_vb=GetListForAuth",
		{
			ManagerID : ""
		,	ManagerName : ""
		,	PageNo : $("div.pager").pager("option", "currentPageNo")
		,	PageSize : $("div.pager").pager("option", "pageSize")
		}, function(results, context)
		{
			$("table.managerList tbody").html(results[0]);
			$("div.pager").pager("update", results[1]);
			$("table.managerList tbody").find("input.m_btnSelect").click(function() {
				var data = $(this).closest("tr").tagdata();
				if ( data.IsManager == 1 ) {
					alert( "전체 관리자 입니다.");
					return;
				} else {
					location.href="/manager/manager/pageauth.aspx?PageNo=" + $("div.pager").pager("option", "currentPageNo") + "&ManagerSN=" + data.n4ManagerSN;
				}
			});
		});
};

$(function() {
	$("div.pager").pager({
		pageSize : 20,
		useCallback : true,
		pageNo : 1,
		currentPageNo : <%=PageNo %>,
		callback:function(pageNo) {
			$.Manager.getList();
		}
	});
	
	$("select.m_selMainPageType").change(function() {
		var data = $(this).closest("td").tagdata();
		var val = $(this).val();
		$.ajaxNet(
		"/manager/manager/pageauthMethod.aspx?_vb=SetPageAuthMain",
		{
			ManagerSN : <%=this.ManagerSN %>
		,	MainPageType : data.MainPageType
		,	CodeAuthType : val
		}, function(results, context)
		{
			alert("변경되었습니다.");
		});
	});
	
	$("select.m_selSubPageType").change(function() {
		var data = $(this).closest("td").tagdata();
		
		var data = $(this).closest("td").tagdata();
		var val = $(this).val();
		$.ajaxNet(
		"/manager/manager/pageauthMethod.aspx?_vb=SetPageAuthSub",
		{
			ManagerSN : <%=this.ManagerSN %>
		,	MainPageType : data.MainPageType
		,	SubPageType : data.SubPageType
		,	CodeAuthType : val
		}, function(results, context)
		{
			alert("변경되었습니다.");
		});
		
	});

	$.Manager.getList();
});
</script>
</asp:Content>
